package Classes.GameViews// ActionScript file
{
	import Classes.GameDatas.GD_Zombie;
	import Classes.GameUtils.StyleManager;
	import Classes.Interfaces.GV_hot;
	import Classes.Interfaces.I_Observer;
	
	import flash.display.Sprite;
	import flash.system.ApplicationDomain;

	public class GV_ZombieHotPanel extends GameView implements I_Observer
	{
		private var _gvData:GV_hot;
		private var _interfaceUI:Sprite;
		public function GV_ZombieHotPanel(gvData:GV_hot):void
		{
			this._gvData=gvData;
			this.init();
		}
		
		private function init():void
		{
			this.mouseEnabled=false;
			this.mouseChildren=false;
			this._interfaceUI=new(ApplicationDomain.currentDomain.getDefinition("ZombieHotShowPanel_v") as Class);
			this.addChild(this.interfaceUI);
			this.showZombieName();
			this.showLife();
			this.addObserverFuncs();
		}
		
		public function addObserverFuncs():void
		{
			this.gvData.addObserverFuncs("life",this);
		}
		
		public function touchObserve(observeType:String):void
		{
			switch(observeType)
			{
				case "life":
					this.showLife();
					break;
			}
		}
		
		private function showZombieName():void
		{
			this.interfaceUI["showZombieName"](this.gvData.gvName,this.gvData.sxTxt,this.gvData.sxTxtCount);
		}
		
		private function showLife():void
		{
			if(this.gvData.lifeMax==0) 
			{
				this.interfaceUI["lifeBar"].visible=false;
				this.interfaceUI["lifeTxt"].visible=false;
			}else{
				this.interfaceUI["setLife"](this.gvData.currentlife,this.gvData.lifeMax);
			}
		}
		
		public function cleanAllObserves():void
		{
			this.gvData.removeOberverFuns("life",this);
		}
		
		public function release():void
		{
			if(this.parent)this.parent.removeChild(this);
			this.removeChild(this.interfaceUI);
			this.cleanAllObserves();
			this._interfaceUI=null;
			this._gvData=null;
		}

		/*getter & setter*/
		public function get interfaceUI():Sprite
		{
			return _interfaceUI;
		}

		public function get gvData():GV_hot
		{
			return _gvData;
		}


	}
}